﻿using Mathmall.Administration.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mathmall.Administration.Data
{
    public class SpuInfoDescEntityTypeConfiguration : IEntityTypeConfiguration<SpuInfoDescription>
    {
        public void Configure(EntityTypeBuilder<SpuInfoDescription> builder)
        {
            // 不使用output子句
            builder.ToTable(table => table.UseSqlOutputClause(false));

            builder
                .ToTable(nameof(SpuInfoDescription))
                .ToTable(tableBuilder => tableBuilder.HasComment("spu信息介绍"));

            builder
                .HasKey(spuInfoDescription => spuInfoDescription.SpuInfoDescriptionID)
                .HasName("SpuInfoDescriptionID");

            builder
                .Property(spuInfoDescription => spuInfoDescription.Description)
                .HasColumnName("Description")
                .HasColumnType("text")
                .HasComment("商品介绍")
                .IsRequired(false);

            builder
                .Property(spuInfo => spuInfo.CreateTime)
                .HasColumnName("CreateTime")
                .HasColumnType("datetime")
                .HasComment("创建时间")
                .IsRequired(false);

            builder
                .Property(spuInfo => spuInfo.LastUpdateTime)
                .HasColumnName("LastUpdateTime")
                .HasColumnType("datetime")
                .HasComment("最后更新时间")
                .IsRequired(false);
        }
    }
}
